/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PantallaPrincipal.java
 *
 * Created on 11-jun-2011, 17:44:34
 */

package asistenciadb;

import java.awt.Font;
import javax.swing.JOptionPane;

/**
 *
 * @author micael
 */
public class PantallaPrincipal extends javax.swing.JFrame {

    private asistenciadb.Hora hora;
    /** Creates new form PantallaPrincipal */
    public PantallaPrincipal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jDialog1 = new javax.swing.JDialog();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        runText = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        passText1 = new javax.swing.JPasswordField();
        jButton3 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(400, 400));
        getContentPane().setLayout(null);

        jLabel1.setText("Ingrese Clave");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(40, 130, 110, 30);

        jButton1.setText("Salir");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(120, 260, 90, 40);

        jLabel2.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); // NOI18N
        jLabel2.setText("SISTEMA DE ASISTENCIA");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(90, 20, 260, 24);
        getContentPane().add(runText);
        runText.setBounds(150, 80, 130, 30);

        jLabel3.setText("Ingrese RUN");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(40, 80, 110, 30);

        jButton2.setText("Consultar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(30, 190, 120, 40);

        passText1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                passText1ActionPerformed(evt);
            }
        });
        getContentPane().add(passText1);
        passText1.setBounds(150, 130, 130, 30);

        jButton3.setText("Ingresar Nuevo Trabajador");
        getContentPane().add(jButton3);
        jButton3.setBounds(190, 180, 170, 60);

        jLabel4.setText("------");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(420, 30, 24, 14);
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Reloj Digital by Contre17");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        System.exit(0);// TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
         int run=Integer.parseInt( this.runText.getText());
         String pass = this.passText1.getText();
    consultas llamada = new consultas();
    llamada.reviza_run(run,pass);// TODO add your handling code here:

        if (llamada.x==0)
            {
            JOptionPane.showMessageDialog(this, "Su RUN ("+run+") no se encuentra en la Base de datos de Funcionarios");
}
        else
        {
        JOptionPane.showMessageDialog(this, "Su RUN ("+run+") es Funcionario");
            //llamada.ingreso_datos(run);//se registra el ingreso al programa a la base de datos


            //Formulario1 form1 = new Formulario1(run,llamada.lastID);
            //form1.setExtendedState(MAXIMIZED_BOTH);//permite iniciar maximizado el jframe que se está creando
            //form1.setLocationRelativeTo(null);// permite que la ventana aparezca en el centro
            //form1.setVisible(true);
            //dispose();//cierra el formulario actual
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void passText1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passText1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_passText1ActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    hora = new asistenciadb.Hora();/***Inicializar la variable hora***/
    hora.setBounds(300, 5, 150, 30);/*(Ubicacion en eje x, Ubicacion en eje y, Ancho, Alto)*/
    hora.setFont(new Font("Trebuchet MS",java.awt.Font.BOLD, 20));/*Cambiamos la fuente, estilo y tamaño*/
    this.add(hora);/*La agregamos al JFrame*/
    }//GEN-LAST:event_formWindowOpened

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PantallaPrincipal().setVisible(true);
            }
        });
    }

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPasswordField passText1;
    private javax.swing.JTextField runText;
    // End of variables declaration//GEN-END:variables

}
